package leftMain;
//package org.dlsu.mt.parser;

import org.dlsu.mt.parser.FStructure;
import org.dlsu.mt.parser.generation.GrammarList;
import org.dlsu.mt.parser.generation.GrammarLoader;
import org.dlsu.mt.parser.generation.HTPLConverter;
import org.dlsu.mt.parser.generation.HTPLInterpreter;
import org.dlsu.mt.parser.generation.Phrase;


public class GenerationModule
{
	private GrammarList list;
	private HTPLConverter convert;
	private HTPLInterpreter interpret;
	
	public GenerationModule(){
		convert = new HTPLConverter();
		interpret = new HTPLInterpreter();
	}
	
	public GenerationModule(String filename) throws Exception
	{
		GrammarLoader loader = new GrammarLoader(filename);
		list = loader.load();
		convert = new HTPLConverter();
		convert.loadGrammarList(list);
		interpret = new HTPLInterpreter();
	}
	
	public void loadGrammar(String filename) throws Exception
	{
		GrammarLoader loader = new GrammarLoader(filename);
		list = loader.load();
		convert.loadGrammarList(list);
	}
	
	public String generateString(FStructure ef) throws Exception
	{
		Phrase p = convert.convert(ef);
		return interpret.interpret(p);
	}

}